package com.klw.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.klw.common.annotation.Log;
import com.klw.common.core.controller.BaseController;
import com.klw.common.core.domain.AjaxResult;
import com.klw.common.enums.BusinessType;
import com.klw.business.domain.KlwMlFeatures;
import com.klw.business.service.IKlwMlFeaturesService;
import com.klw.common.utils.poi.ExcelUtil;
import com.klw.common.core.page.TableDataInfo;

/**
 * 机器学习特征Controller
 * 
 * @author klw
 * @date 2025-08-24
 */
@RestController
@RequestMapping("/base/features")
public class KlwMlFeaturesController extends BaseController
{
    @Autowired
    private IKlwMlFeaturesService klwMlFeaturesService;

    /**
     * 查询机器学习特征列表
     */
    @PreAuthorize("@ss.hasPermi('base:features:list')")
    @GetMapping("/list")
    public TableDataInfo list(KlwMlFeatures klwMlFeatures)
    {
        startPage();
        List<KlwMlFeatures> list = klwMlFeaturesService.selectKlwMlFeaturesList(klwMlFeatures);
        return getDataTable(list);
    }

    /**
     * 导出机器学习特征列表
     */
    @PreAuthorize("@ss.hasPermi('base:features:export')")
    @Log(title = "机器学习特征", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KlwMlFeatures klwMlFeatures)
    {
        List<KlwMlFeatures> list = klwMlFeaturesService.selectKlwMlFeaturesList(klwMlFeatures);
        ExcelUtil<KlwMlFeatures> util = new ExcelUtil<KlwMlFeatures>(KlwMlFeatures.class);
        util.exportExcel(response, list, "机器学习特征数据");
    }

    /**
     * 获取机器学习特征详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:features:query')")
    @GetMapping(value = "/{featureId}")
    public AjaxResult getInfo(@PathVariable("featureId") Long featureId)
    {
        return success(klwMlFeaturesService.selectKlwMlFeaturesByFeatureId(featureId));
    }

    /**
     * 新增机器学习特征
     */
    @PreAuthorize("@ss.hasPermi('base:features:add')")
    @Log(title = "机器学习特征", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KlwMlFeatures klwMlFeatures)
    {
        return toAjax(klwMlFeaturesService.insertKlwMlFeatures(klwMlFeatures));
    }

    /**
     * 修改机器学习特征
     */
    @PreAuthorize("@ss.hasPermi('base:features:edit')")
    @Log(title = "机器学习特征", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KlwMlFeatures klwMlFeatures)
    {
        return toAjax(klwMlFeaturesService.updateKlwMlFeatures(klwMlFeatures));
    }

    /**
     * 删除机器学习特征
     */
    @PreAuthorize("@ss.hasPermi('base:features:remove')")
    @Log(title = "机器学习特征", businessType = BusinessType.DELETE)
	@DeleteMapping("/{featureIds}")
    public AjaxResult remove(@PathVariable Long[] featureIds)
    {
        return toAjax(klwMlFeaturesService.deleteKlwMlFeaturesByFeatureIds(featureIds));
    }
}
